from sympy import (
    symbols, simplify, sin, cos, exp,
    expand, factor, collect, cancel, apart, 
    diff, integrate, oo,
    series, solveset, S, Eq, dsolve, Function,
    Matrix, eye, zeros, ones, diag,
    latex, sqrt)
from sympy.abc import x, y, z

# alpha_mu = symbols('alpha_mu')
# print(simplify(2*sin(alpha_mu)*cos(alpha_mu)))

# x_1 = symbols('x_1')
# print(expand((x_1 + 1)**2))

# print(factor(x**3 - x**2 + x - 1))

# expr = x*y + x - 3 + 2*x**2 - z*x**2 + x**3
# print(collect(expr, x))

# print(cancel((x**2 + 2*x + 1)/(x**2 + x)))

# expr = (4*x**3 + 21*x**2 + 10*x + 12)/(x**4 + 5*x**3 + 5*x**2 + 4*x)
# print(apart(expr))

# print(diff(cos(x), x))
# print(diff(x**4, x, 3))
# expr = cos(x)
# print(expr.diff(x, 2))
# expr = exp(x*y*z)
# print(diff(expr, x))

# print(integrate(cos(x), x))
# print(integrate(exp(-x), (x, 0, oo)))
# print(integrate(exp(-x**2 - y**2), (x, -oo, oo), (y, -oo, oo)))

# print(limit(sin(x)/x, x, 0))
# print(limit(1/x, x, 0, '+'))

# expr = sin(x)
# print(expr.series(x, 0, 4))

# print(solveset(Eq(x**2 - x, 0), x, domain = S.Reals))

# f = symbols('f', cls=Function)
# diffeq = Eq(f(x).diff(x, 2) - 2*f(x).diff(x) + f(x), sin(x))
# print(dsolve(diffeq, f(x)))

# print(Matrix([[1, -1], [3, 4], [0, 2]]))
# print(Matrix([1, 2, 3]))
# print(Matrix([[1], [2], [3]]).T)
# print(eye(4))
# print(zeros(4))
# print(ones(4))
# print(diag(1, 2, 3, 4))
# M = Matrix([[1, 3], [-2, 3]])
# print(M**2)
# print(M**-1)
# M = Matrix([[1, 0, 1], [2, -1, 3], [4, 3, 2]])
# print(M.det())
# M = Matrix([[3, -2,  4, -2], [5,  3, -3, -2], [5, -2,  2, -2], [5, -2, -3,  3]])
# print(M.eigenvals())
# lamda = symbols('lamda')
# p = M.charpoly(lamda)
# print(factor(p))

# from sympy.plotting import plot
# plot(x**2, (x, -2, 2))

# from sympy import plot_implicit
# from sympy import Eq
# plot_implicit(Eq(x**2 + y**2, 1))

# from sympy.plotting import plot3d
# from sympy import exp
# plot3d(x*exp(-x**2 - y**2), (x, -3, 3), (y, -2, 2))

# # 输出运算结果的 LATEX 代码
# print(latex(integrate(sqrt(x), x)))


